#pragma once

#include <iostream>
#include <utility>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <list>

using namespace std;

typedef pair< string, int > CSV_STAT;
typedef std::vector< std::string > csvVector;

class cCsvCallback
{
public:
    virtual bool Execute(csvVector &cl) const =0;
};


template <class cInstance>
class TCsvCallback : public cCsvCallback
{
public:
    TCsvCallback()          // constructor
    {
        pFunction = 0;
    }

    typedef bool (cInstance::*tFunction)(csvVector &cl);

    virtual bool Execute(csvVector &cl) const 
    {
        if (pFunction) 
            return (cInst->*pFunction)(cl);
        else {
            std::wcout << L"ERROR : the callback function has not been defined !!!!" << std::endl;
            return false;
        }
    }

    void SetCallback (cInstance  *cInstancePointer, 
        tFunction   pFunctionPointer)
    {
        cInst     = cInstancePointer;
        pFunction = pFunctionPointer;
    }

private:
    cInstance  *cInst;
    tFunction  pFunction;
};




/*
// typedef to save typing for the following object
typedef std::vector< std::vector<std::wstring> > csvVector;

typedef std::pair< unsigned long, unsigned long > CSV_STAT;

typedef std::map< std::string,CSV_STAT > CSV_MAP;
*/

class CCsv {
    //CCsv();
    //~CCsv();
protected:
    bool Split(csvVector &cl);
   
    bool AnalyzeStat(csvVector &cl);

 
  public:
    list<CSV_STAT> mylist;
   //map<

    bool Analyze(string &filename);
   
    void SplitCsv(string &filename,int NumberBlock, int t);
 
    bool AnalyzeCsv(string &filename,cCsvCallback *p_CallbackOutput);
       
    void ShowListClass();
};


